﻿using UIFramework;
using UnityEngine;
using UnityEngine.EventSystems;

namespace Game.Logic.Login
{
    public class LoginController : GameUIController
    {
        public LoginView LoginView { private set; get; }
        public LoginModel LoginModel { private set; get; }

        public LoginController(Transform canvasTransform, UIContext uiContext) : base(canvasTransform, uiContext)
        {
        }

        public override void OnEnter()
        {
            LoginView = View as LoginView;
            LoginModel = Model as LoginModel;
            base.OnEnter();
        }

        public void OnClickLogout(GameObject go, BaseEventData eventData)
        {
            LoginModel.CancelUserDataAccountInfo();
        }

        public void OnClickLogin(GameObject go, BaseEventData eventData)
        {
            string account = LoginView.InputLoginAccount.text;
            string password = LoginView.InputLoginPassword.text;
            LoginModel.OnLoginGame(account, password, LoginView.IsRegister);
        }
    }
}
